/*
 * XYZCustomNeighborhood.java
 *
 * Created on April 1, 2005, 9:05 AM
 */

package edu.temple.GUS.MMA.Neighborhoods;

import edu.temple.GUS.MMA.DataTypes.*;

/**
 *
 * @author jleong
 */
public class XYZCustomNeighborhood extends XYZNeighborhood{
    
    private boolean filter[][][];

    /** Creates a new instance of XYZCustomNeighborhood */
    public XYZCustomNeighborhood(int x, int y, int z, boolean filter[][][])
    {
        // Define the x, y and z extend of the neighborhood
        super(x,y,z);
        this.filter = filter;
    }

    /** Creates a new instance of XYZCustomNeighborhood */
    public XYZCustomNeighborhood(MMASpaceCube filterCube)
    {
        // Define the x, y and z extend of the neighborhood
        super(filterCube.getX(),filterCube.getY(),filterCube.getZ());
        
        int x = filterCube.getX();
        int y = filterCube.getY();
        int z = filterCube.getZ();
        float noData = filterCube.getNoData();
        
        // Create a customed filter
        filter = new boolean[z][y][x];
        
        for (int k=0; k<z; k++)
            for (int j=0; j<=y; j++)
                for (int i=0; i<=x; i++)
                {
                    if ( filterCube.getElement(i,j,k) == noData )
                        filter[k][j][i] = false;
                    else
                        filter[k][j][i] = true;
                }
    }
    
    public boolean getFilterElement(int x, int y, int z) { return filter[z][y][x];}
}
